package org.example.seatunnel;

import com.typesafe.config.Config;
import org.example.seatunnel.model.SinkResModel;
import org.example.seatunnel.model.SourceResModel;

import java.util.ArrayList;
import java.util.List;

public class SeatunnelSinkWrapper {

    static List<SeatunnelSink> sinkList = new ArrayList<>();

    static {
        sinkList.add(new SeatunnelJdbcSink());
    }

    private static SeatunnelSink getSeatunnelSink(Config config){
        for (SeatunnelSink sink : sinkList) {
            if(sink.isSupport(config)){
                return sink;
            }
        }
        System.out.println(config);
        throw new RuntimeException("配置未能找到解析器"+config.entrySet().stream().findFirst().get().getKey());
    }

   public  static SinkResModel parse(SourceResModel sourceResModel, Config config){
       SeatunnelSink seatunnelSink = getSeatunnelSink(config);

       SinkResModel sourceResModelr = seatunnelSink.parse(sourceResModel,config);

       return sourceResModelr;
   }

}
